<template>
   <div class="all">
     <div class="add-nav">
       <ul>
         <li v-for="(val,name) in list" @click="msgGET(name)" :class="{list:select===name}">{{val}}</li>
       </ul>
     </div>
     <div >
     <!-- 基本设置 -->
      <div v-show="select==='basic'" >
<div class="Param">
  <table width="100%">
            <tbody>
              <tr>
                <th width="120">关闭站点</th>
                  <td>
                      <input type="radio" id="one" value="1" v-model="date.basic.closeSite">
                        <label for="1">是</label>
                        <input type="radio" id="two" value="0" v-model="date.basic.closeSite">
                        <label for="0">否</label>
                        <font color="gray">管理员可访问前台及后台</font>
                  </td>
              </tr>
            <tr>
                <th width="120">关站提示</th>
                <td>
                    <input type="text" value="" v-model="date.basic.closeTip">
                      <font color="gray">关闭站点前台访问提示</font>
                </td>
          </tr>
            <tr>
              <th width="120">              网站LOGO路径	            </th>
              <td>
                <input type="text" value="date.basic.logo" v-model="date.basic.logo">
                 <font color="gray">请输入网站LOGO路径</font>
              </td>
            </tr>
            <tr>
              <th width="120">网站名称</th>
              <td>
                <input type="text" value="date.basic.siteName" v-model="date.basic.siteName">
                <font color="gray">请输入网站名称</font>
              </td>
            </tr>
            <tr>
              <th width="120">网站标题	</th>
              <td>
                <input type="text" value="date.basic.siteTitle" v-model="date.basic.siteTitle">

              </td>
            </tr>
            <tr>
              <th width="120">网站URL</th>
              <td>
                <input type="text" value="date.basic.siteUrl" v-model="date.basic.siteUrl">

              </td>
            </tr>
            <tr>
              <th width="120">网站域名根</th>
              <td>
                <input type="text" value="date.basic.siteDomain" v-model="date.basic.siteDomain">

              </td>
            </tr>
            <tr>
              <th width="120">页脚版权信息</th>
              <td>
                <textarea id="footinfo" style="height: 110px; width: 619px; visibility: inherit; margin: 0px;" value="date.basic.copyright" v-model="date.basic.copyright"></textarea>
  <font color="gray">页脚版权信息,支持HTML</font>
              </td>
            </tr>
            </tbody>
          </table>

</div>

  <button @click="Submit()">提交</button>
      </div>
      <!-- SEO相关设置 -->
        <div v-show="select==='SEO'">
          <div class="Param">
            <table width="100%">
                      <tbody>
            <tr>
              <th width="120">网站标题后缀</th>
              <td>
                <input type="text"  v-model="date.SEO.titleSuffix">

              </td>
            </tr>
            <tr>
              <th width="120">meta关键字</th>
              <td>
                <input type="text"  v-model="date.SEO.meta">
              </td>
            </tr>
            <tr>
                        <th width="120">meta描述</th>
                        <td>
<textarea id="footinfo" style="height: 110px; width: 619px; visibility: inherit; margin: 0px;"  v-model="date.SEO.metadesc"></textarea>
                        </td>
                      </tr>
            </tbody>
            </table>
          </div>
  <button>提交</button>

        </div>
        <!-- 注册设置 -->
          <div v-show="select==='login'">
            <div class="Param">
              <table width="100%">
                <tbody>
                  <tr>
                    <th>开放注册</th>
                    <td>
                      <input type="radio" id="one" value="1" v-model="date.login.allowReg">
                        <label for="1">是</label>
                        <input type="radio" id="two" value="0" v-model="date.login.allowReg">
                        <label for="0">否</label>
                    </td>
                  </tr>
                  <tr>
                    <th>注册默认审核</th>
                    <td>                    <input type="radio" id="one" value="1" v-model="date.login.needCheck">
                      <label for="1">是</label>
                      <input type="radio" id="two" value="0" v-model="date.login.needCheck">
                      <label for="0">否</label></td>

                  </tr>
                  <tr>
                       <th width="120">禁止注册用户名	</th>
                       <td>
                        <textarea id="footinfo" style="height: 110px; width: 619px; visibility: inherit; margin: 0px;"  v-model="date.login.forbidden"></textarea>
                       <font color="gray"> 多个用户名以逗号‘,’分隔</font>
                         </td>
                   </tr>
                   <tr>
                     <th width="120">UC访问地址</th>
                     <td>
                       <input type="text"  v-model="date.login.ucUrl">
                     </td>
                   </tr>
                </tbody>
              </table>
            </div>
              <button>提交</button>
          </div>
          <!-- 直播设置 -->
            <div v-show="select==='live'">
              <div class="Param">
                <table width="100%">
                  <tbody>
                    <tr>
                      <th>默认直播权限</th>
                      <td>
                        <input type="radio" id="one" value="1" v-model="date.live.liveAccess">
                          <label for="1">有</label>
                          <input type="radio" id="two" value="0" v-model="date.live.liveAccess">
                          <label for="0">无</label>
                      </td>
                    </tr>
                      <tr>
                        <th>人民币与虚拟币比例</th>
                        <td>1:<input type="text" value="date.live.ratio"  size="5" v-model="date.live.ratio">
                        <font color="gray">修改比例时请确保当前主播及代理的各项款项已结清</font>
                        </td>
                      </tr>
                      <tr>
                        <th>CDN地址	</th>
                        <td>
                          <input type="text" value="date.live.cdn" v-model="date.live.cdn">
                        </td>
                      </tr>
                      <tr>
                        <th>
                          cdn拉流地址
                        </th>
                        <td>
                          <input type="text" value="date.live.cdnPullUrl" v-model="date.live.cdnPullUrl">
                            <font color="gray">主播视频流拉流</font>
                        </td>
                      </tr>
        <tr>
            <th>fps	</th>
        <td>
          <input type="text"  size="5" v-model="date.live.cdnPullUrl">
        </td>
        </tr>
            <tr>
              <th>最大比特率	</th>
              <td><input type="text"  size="5" v-model="date.live.maxBit"></td>
            </tr>
            <tr>
              <th>品质</th>
              <td><input type="text"  size="5" v-model="date.live.quality"></td>
            </tr>
            <tr>
              <th>关键帧间隔</th>
               <td><input type="text"  size="5" v-model="date.live.frame"></td>
            </tr>
            <tr>
              <th>分辨率宽度</th>
              <td><input type="text"  size="5" v-model="date.live.resolutionWidth"></td>
            </tr>
            <tr>
              <th>
                分辨率高度
              </th>
              <td><input type="text"  size="5" v-model="date.live.resolutionHeight"></td>
            </tr>
            <tr>
              <th>是否开启文字</th>
              <td><el-switch
            v-model="date.live.character"
            active-color="#13ce66"
            inactive-color="#ff4949">
                </el-switch>
</td>
            </tr>
            <tr>
              <th>是否开启视频</th>
              <td>
                <el-switch
                v-model="date.live.video"
                active-color="#13ce66"
                inactive-color="#ff4949">
                    </el-switch>
              </td>
            </tr>
            <tr>
              <th>是否开启地址</th>
              <td>
                <el-switch
                v-model="date.live.site"
                active-color="#13ce66"
                inactive-color="#ff4949">
                    </el-switch>
              </td>
            </tr>
            <tr>
              <th>是否开启图片</th>
              <td>
                <el-switch
                v-model="date.live.site"
                active-color="#13ce66"
                inactive-color="#ff4949">
                    </el-switch>
              </td>
            </tr>
                    </tbody>
                </table>
              </div>
               <button>提交</button>
            </div>
            </div>
     </div>
</template>

<script>
  export default{
    name:'Addadmin',
    inject: ['reload'],
    data () {
       return{
        date:{
        basic:{
          closeSite:0,//服务状态
          closeTip:'',//关站提示
          logo:'',//网站LOGO
          siteUrl:'',//网站URL
          siteName:'',//网站名称
          siteTitle:'',//网站标题
          copyright:'',//页脚版权信息
          siteDomain:'',//网站域名根
        },
        //SEO
        SEO:{
          titleSuffix:'',//网站标题后缀
          meta:'',//meta关键字
          metadesc:'',//	meta描述
        },
        //注册
        login:{
          allowReg:'',//开放注册
          needCheck:'',//注册默认审核
          forbidden:'',//禁止注册用户名
          ucUrl:'',//UC访问地址
        },
        //live
        live:{
          liveAccess:'',//默认直播权限
          ratio:'',//货币比例
          cdn:'',//cdn
          cdnPullUrl:"",//cdn拉流
          maxBit:'',//最大比特率
          quality:'',//品质
          frame:'',//关键帧间隔
          resolutionWidth:'',//分辨率宽度
          resolutionHeight:'',//分辨率高度
          character:'',//开启文字
          video:'',//开启视频
          site:'',//开启地址
          picture:'',//开启图片

        }
        },
         list:{
           basic:'基本设置',
           SEO:'SEO相关设置',
           login:'注册设置',
           live:'直播设置',


         },
        select:'basic',
         }
    },
     methods:{
       msgGET:function(e){
         this.select=e
         var data={
           basic:'admin/config/base/get',
           SEO:'admin/config/SEO/get',
           login:'admin/config/register/get',
           live:'admin/config/live/get'
         }

         this.Postdata(data[e],e)
       },
       Postdata(e,c){
         var _this=this
         this.$axios({
           method: "POST",
               url: '/api/'+e,
               data: {
            adminName:_this.$cookies.get('adminName'),
            token:_this.$cookies.get('token')
           },
           headers: {
                   'Content-Type': 'application/json'
                    }
         }).then(function(response){
           if(response.data.data){
             _this.date[c]=response.data.data
           }else{
             this.reload()
           }

            console.log(response)
          })
          .catch(function(error){
            console.log(error)
          })
       },
       Submit(){
         var _this=this
        var data={
          basic:'admin/config/base/set',
          SEO:'admin/config/SEO/set',
          login:'admin/config/register/set',
          live:'admin/config/live/set'
        }
         var c=this.select
        this.$axios({
          method:"POST",
          url:'/api/'+data[c],
          data:{adminName:_this.$cookies.get('adminName'),
                token:_this.$cookies.get('token'),
                //basic
                closeSite:_this.date.basic.closeSite,
                closeTip:_this.date.basic.closeTip,
                logo:_this.date.basic.logo,
                siteName:_this.date.basic.siteName,
                siteTitle:_this.date.basic.siteTitle,
                siteUrl:_this.date.basic.siteUrl,
                siteDomain:_this.date.basic.siteDomain,
                copyright	:_this.date.basic.copyright,
                //SEO
                titleSuffix:_this.date.SEO.titleSuffix,
                META:_this.date.SEO.mata,
                METAdesc:_this.date.SEO.matadesc,
                //login
                allowReg:_this.date.login.allowReg,
                needCheck:_this.date.login.needCheck,
                forbidden:_this.date.login.forbidden,
                ucUrl:_this.date.login.ucUrl,
                //live
                liveAccess:_this.date.live.liveAccess,
                ratio:_this.date.live.ratio,
                cdn:_this.date.live.cdn,
                cdnPullUrl:_this.date.live.cdnPullUrl,
                fps:_this.date.live.fps,
                maxBit:_this.date.live.maxBit,
                quality:_this.date.live.quality,
                frame:_this.date.live.frame,
                resolutionWidth:_this.date.live.resolutionWidth,
                resolutionHeight:_this.date.live.resolutionHeight,
            },
        headers: {
                  'Content-Type': 'application/json'
                   }
        }).then(function(response){

           console.log(response)
         })
         .catch(function(error){
           console.log(error)
         })
       }
     },
     mounted(){
       this.Postdata('admin/config/base/get',this.select)
     }


    }
</script>

<style lang="scss" scoped src = "../../css/system.css">

</style>
